<template>
  <div class="ColumnList">
        <div class="ColumnList-title">
      <span v-if="columnName">{{ columnName }}</span>
      <span v-else>列表</span>
    </div>
    <div class="ColumnList-content" v-if="columnContent.length != 0">
      <template v-for="(item, index) in columnContent">
        <div class="ColumnList-content-box">
          <div class="left">
            <img :src="item.picUrl" @click="updateColumnClick(index)" />
          </div>
          <div class="right">
            <div class="title">{{ item.elementName }}</div>

            <div class="content">
              <span>{{ item.lecturerCompany }}</span>
              <!-- <span>{{ item.lecturerName }}</span> -->
            </div>
            <!-- <div class="label">
              <span>{{ item.studentCount }}</span>
            </div> -->
          </div>
        </div>
      </template>

      <div class="ColumnList-content-box">
        <div class="left">
          <div class="null-div" @click="updateColumnClick">
            <img src="../../../assets/qxbNull.png" />
            <p>
              <span>+</span>
              <span v-if="columnName">{{ columnName }}</span>
              <span v-else>列表</span>
            </p>
          </div>
        </div>
        <div class="right">
          <div class="title">内容标题内容标题内容标题内容标题内容标题内容标题内容标题内容标题</div>
          <div class="content">
            <span>讲师姓名</span>
            <!-- <span>讲师职位</span> -->
          </div>
          <!-- <div class="label">
            <span>标签</span>
          </div> -->
      </div>
    </div>
    </div>

    <!-- 栏目为空时，显示默认占位盒 -->
    <div class="ColumnList-content-null" v-else>
      <div class="ColumnList-content-box">
        <div class="left">
          <div class="null-div" @click="updateColumnClick">
            <img src="../../../assets/qxbNull.png" />
            <p>
              <span>+</span>
              <span v-if="columnName">{{ columnName }}</span>
              <span v-else>列表</span>
            </p>
          </div>
        </div>
        <div class="right">
          <div class="title">内容标题内容标题内容标题内容标题内容标题内容标题内容标题内容标题</div>
          <div class="content">
            <span>讲师姓名</span>
            <!-- <span>讲师职位</span> -->
          </div>
          <!-- <div class="label">
            <span>标签</span>
          </div> -->
        </div>
      </div>

    </div>
  </div>
</template>

<script type="ts">
import {computed, defineComponent,reactive} from "vue";

export default defineComponent({
// props: ['updateColumn'],
  props: ['attrData','updateColumn'],

  setup (props) {
    const columnName = computed(() => {
      return props.attrData.columnName;
    })

    const columnContent = computed(() => {
      return props.attrData.columnContent || [];
    })
    const updateColumnClick = (index) => {
      console.log(columnContent, index, columnContent.value[index], 'columnContent123')
      const item = columnContent.value[index]
      props.updateColumn({
        ...item
      })
    }


    return {
      columnName,
      columnContent,
      updateColumnClick,

    }
  }
});
</script>

<style lang="scss" scoped>
.ColumnList {
  width: 100%;
  max-width: 290px;
  display: flex;
  flex-direction: column;

  .ColumnList-title {
    font-size: 18px;
    color: #333;
    margin-bottom: 10px;
  }
  .ColumnList-content,
  .ColumnList-content-null {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    .ColumnList-content-box {
      width: 48%;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20px;
      .left {
        width: 100%;
        height: 100%;
        overflow: hidden;
        img {
          width: 100px;
          height: 100%;
          border-radius: 8px;
        }
      }

      .right{
        width: 100%;
        padding: 8px;
        background: #f8f8f8;
        border-radius: 0 0 8px 8px;
        .title{
          width: 100%;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          color: rgba(0,0,0,.9);
    font-size: 15px;
    line-height: 24px;
        }

        .content{
          margin: 5px 0;
          span{
            color: rgba(0,0,0,.6)
          }
        }
      }
    }
  }

  .ColumnList-content-box {
    .left {
      .null-div {
        
        width: 100%;

        height: 100%;
        background: rgba(0, 0, 0, 0.07);
        border-radius: 8px 8px 0 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 10px 0;
        img {
          width: 55px;
        }
        p {
          margin: 0;
          color: rgba(0, 0, 0, 0.6);
          font-weight: 400;
          text-align: center;
          font-size: 12px;
        }
      }
    }

  }
}
</style>
